package cn.lcsjsxy.yxc.objectoriented.运算符的回顾;

public class Person {
    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean equals(Object obj){
        if(this == obj)
            return true;
        if(obj instanceof Person){
            Person objPerson=(Person)obj;
            //比较两个对象的属性是否都相同
            return this.age == objPerson.age && this.name.equals(objPerson.name);
        }
        return false;
    }
}
